﻿CREATE PROCEDURE [ServiceEngine].[ListSchemaObjectDependencies]
@ParentObjectID UNIQUEIDENTIFIER
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
	SELECT 
		SO.[SchemaObjectID],
		SO.[SchemaObjectName],
		SO.[SchemaObjectType],
		SO.[SchemaObjectXml],
		N.[EntityName],
		SO.DataEntityID
	FROM 
		[SchemaObjects] SO JOIN [SchemaObjectDependencies] SOD ON SO.SchemaObjectID = SOD.SchemaObjectID 
		JOIN [Names] N ON N.EntityID = SO.SchemaID
	WHERE 
		SOD.ParentObjectID = @ParentObjectID --AND SO.DateRevised IS NULL
END